<?php
require '../../../wp-load.php';
$getid = $_GET['id'];
// 메타데이터 추출
$menu_image1_src = get_post_meta($getid, "_menu_image1_src");
$menu_image2_src = get_post_meta($getid, "_menu_image2_src");
$menu_type = get_post_meta($getid, "_menu_type");

// 이미지 미리보기 위한 태그 생성
$image1_img_tag = "미등록";
$image2_img_tag = "미등록";
if( isset($menu_image1_src[0]) && $menu_image1_src[0] ){
    $image1_img_tag = '<img src="'.WP_PLUGIN_URL."/seoul-menu/files/".$menu_image1_src[0].'" />';
}

if( isset($menu_image2_src[0]) && $menu_image2_src[0] ){
    $image2_img_tag = '<img src="'.WP_PLUGIN_URL."/seoul-menu/files/".$menu_image2_src[0].'" />';
}

// 메뉴 타입 radio 체크 상태 설정
$image_checked = "";
$text_checked = "";
if(isset($menu_type[0]) && $menu_type[0] == "image"){
    $image_checked = "checked";
}else{
    $text_checked = "checked";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"  dir="ltr" lang="ko-KR-bk">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Menu Image Iframe</title>

<script type='text/javascript' src='<?php echo get_bloginfo("wpurl");?>/wp-includes/js/jquery/jquery.js'></script>

<script type="text/javascript"> 

jQuery(function($){
        
});

function checkImageForm(){  
    
    if(jQuery("#menu-image1").val() != "" || jQuery("#menu-image2").val() != "") {
        if( !confirm('업로드시 기존 등록된 이미지는 삭제됩니다\n업로드 하시겠습니까?')) {
            return false;
        }
    }
    return true;
}
//]]>
</script>
<style type="text/css">
body { 
    margin:0px;
}
.menu-image-table {
   font-family:"Lucida Grande","Verdana, Arial","Bitstream Vera Sans","sans-serif";
   font-size:12px;
   width:100%; 
}
.menu-image-table td {
    height:25px;
}

.field-name {
    width:100px;
}
.submit-btn-td {
    text-align:right;
}
</style>
</head>

<body>
<form name="menu-image-form-<?php echo $getid;?>" action="./seoul-menu-image.php" method="post" enctype="multipart/form-data" onsubmit="return checkImageForm();">
<fieldset style="text-align:left;width:377px;border:1px solid #CCCCCC;padding: 3px;">
<legend style="margin-left:5px;">Navigation Image</legend>
    <table class="menu-image-table">
        <input type="hidden" id="menu-id" name="menu-id" value="<?php echo $getid;?>">
        <tr>        
            <td class="field-name">기본이미지</td> 
            <td><input type="file" id="menu-image1" name="menu-image1" /></td>
        </tr>

        <tr>
            <td class="field-name">등록여부</td>
            <td><?php echo $image1_img_tag;?></td>            
        </tr>

        <tr>    
            <td class="field-name">오버이미지</td>
            <td><input type="file" id="menu-image2" name="menu-image2" /></td>
        </tr>

        <tr>
            <td class="field-name">등록여부</td>
            <td><?php echo $image2_img_tag;?></td>           
        </tr>
        
        <tr>
            <td class="field-name">메뉴타입</td>
            <td>
                <input type="radio" name="menu-type" value="text"  <?php echo $text_checked;?>/> 텍스트
                <input type="radio" name="menu-type" value="image" <?php echo $image_checked;?> /> 이미지
            </td>           
        </tr>

        <tr>
            <td class="submit-btn-td" colspan="2"><input type="submit" class="submit-btn" value="확인" /></td>
        </tr>
    </table>
</fieldset>
</form>
</body>
</html>